<?php
	// load the theme options
	$options = get_option( 'complete_theme_settings' );
	// set pricing table count
	if($options['pricing_table_count']) { $pricing_table_count = $options['pricing_table_count']; } else { $pricing_table_count = 4; }
?>
<?php
/*
Template Name: Pricing Tables
*/
?>
<?php get_header(' '); ?>
    <div id="main" class="clearfix">
		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <h1 id="page-title"><?php the_title(' '); ?></h1>			
        <?php the_content(' '); ?>
        <?php endwhile; ?>
        <?php endif; ?>	
		<?php
            global $post;
            $args = array(
            	'post_type' =>'pricing',
            	'numberposts' => -1,
            	'orderby' => 'ASC'
            );
            $pricing_posts = get_posts($args);
        ?>
    	<?php if($pricing_posts) { ?>
        <div id="pricing-tables" class="clearfix">
        <?php foreach($pricing_posts as $post) : setup_postdata($post); ?>
            <div class="pricing-plan  pricing-count-<?php echo $pricing_table_count ?>">
                <h3><?php the_title(' '); ?></h3>
                <div class="pricing-plan-cost">
                    <?php echo get_post_meta($post->ID, 'pricing_price', TRUE); ?>
                </div>
                <!-- END pricing-plan-cost -->
                <div class="pricing-plan-features">
                    <?php the_content(' '); ?>
                </div>
                <!-- END pricing-plan-features -->
                <?php
                //check if pricing URL exists and show link
                $pricing_url = get_post_meta($post->ID, 'pricing_url', TRUE);
                $url_title = get_post_meta($post->ID, 'pricing_url_title', TRUE);
                if($pricing_url != '') { ?>
                <a href="<?php echo $pricing_url ?>" title="<?php echo $pricing_url ?>" class="pricing-button"><span><?php echo $url_title ?></span></a>
                <?php } ?>
            </div>
            <!-- END pricing-plan-->
            <?php endforeach; ?>
        </div>
        <!--END pricing-tables -->
<?php } wp_reset_postdata(); // reset the query ?>
<?php get_footer(' '); ?>